package com.example.chessbattleplatform.Pojo;


import cn.hutool.core.net.NetUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


@Slf4j
@Component
@Data
@AllArgsConstructor
@NoArgsConstructor

// 软件配置类
public class AppConfig {

    public static final String JSON_FILE_UTILS_PATH = "./DataFile/json/";


    @Value("${server.port}")
    private int serverPort;

    @Value("${com.exe.openBrowser}")
    private boolean openBrowser = true;

    @Value("${com.storage.uploadPath}")
    private String uploadPath = "./DataFile/path"; // 设置默认值



    private static String host;

    static {
        String localhostStr = NetUtil.getLocalhostStr();

        if (localhostStr != null) {
            host = "http://" + localhostStr + ":";
        } else {
            host = "http://localhost:";
        }
    }

    // 获取本地网站的地址，并加上本地网站的端口号
    public String getLocalhostPort() {
        return host + serverPort + "/WaitRoom.html";
    }


}

